<load href="../Public/js/module/App/app.js"/>
<script>
    $(function(){
        var app = new App();
    
        app.init().init();

    });


    function App(){
        this.init = function(){
            return APP;
        };
    
        var APP = {
            init : function(){
                APP.listeners.bindEvents();
            },
        
            listeners : {
                bindEvents : function(){
                    $.util.foreachFunction(this, [ "bindEvents" ]);
                },
                //跳转至手工添加App页面
                bindAddAppPage : function(){
                    $('#btn_app_add_page').click(function(){
                        $.util.initHiddenFormSubmit($('#frm_hidden_app'),SYSTEM_DATA.contextPath + '/App/appAddPage.shtml',  []);
                    });
                },
                //自动抓取的数据跳转页面
                bindAutoLoadUpdate : function(){
                    $('#table_agents_manager .a_type_update_auto_load').click(function(){
                        $.util.initHiddenFormSubmit($('#frm_hidden_app'), SYSTEM_DATA.contextPath + '/App/appAutoLoadPage.shtml',[{
                                'name' : 'id',
                                'value' : $(this).attr('t_id')
                            }]);
                    });
                },
            
                bindUpdate : function(){
                    $("#table_agents_manager a.a_type_update").click(function(){
                        $.util.initHiddenFormSubmit($('#frm_hidden_app'), SYSTEM_DATA.contextPath + '/App/findAppUpdatePage.shtml',[{
                                'name' : 'id',
                                'value' : $(this).attr('t_id')
                            }]);
                    });
                },
                bindAppFine : function(){
                    $('#table_agents_manager .a_type_fine').click(function(){
                        var $this = $(this);
                        $('#content').showLoading();
                    
                        $.post(SYSTEM_DATA.contextPath + '/App/appFine.shtml', {
                            'id' : $this.attr('t_id'),
                            'fine' : $this.attr('fine')
                        }, function(jsonResponse){
                            if(0 == jsonResponse.status){
                                alert(jsonResponse.info);
                            }else{
                                //更新显示信息
                                var tdText = '是';
                                var aText = '取消精品推荐';
                            
                                $this.attr('fine', 0);
                                if(0 == jsonResponse.data){
                                    tdText = '否';
                                    aText = '添加精品推荐';
                                
                                    $this.attr('fine', 1);
                                }
                                APP.funs.modifyText($this, aText);
                                APP.funs.modifyText($('#table_agents_manager td[t_id="' + $this.attr('t_id') + '"]'), tdText);
                            
                                $('#content').hideLoading();
                                alert(jsonResponse.info);
                            
                            }
                        }, 'json');
                    });
                },
                bindAppDelete : function(){
                    $('#table_agents_manager .a_type_delete').click(function(){
                        if(confirm('数据删除后将无法恢复，是否确定删除？')){
                            $.util.initHiddenFormSubmit($('#frm_hidden_app'), SYSTEM_DATA.contextPath + '/App/appDelete.shtml',[{
                                    'name' : 'id',
                                    'value' : $(this).attr('t_id')
                                }]);
                        }
                    });
                }
            },
        
            funs : {
                modifyText : function($element, text){
                    $element.text(text);
                }
            }
            
        }
    };
</script>

<div id="div_agents_manager_personnel_dialog"><div id="div_agents_manager_personnel_tree"></div></div>

<div class="sendTitleDiv marginleft10">
    App管理[{$typeName }]
</div>
<div class="margintop20 floatRightDiv marginright80">
    <form action="__URL__/app.shtml"  method="post">
        <div class="floatLeftDiv marginleft50">
            <input type="hidden" name="release" value="{$release }"/>
            <input type="hidden" name="type" value="{$type }"/>
            <input type="text" name="app_name" value="{$appName }" class="buttonStyle" />
            <input type="submit" value="搜索" class="buttonStyle" />

            <input id="btn_app_add_page" type="button" value="添加" class="buttonStyle" />
        </div>
    </form>
</div>
<div class="tableInfoDiv margintop10">
    <table id="table_agents_manager">
        <tr>
            <td>
                名称
            </td>
            <!--<td>
                是否为精品推荐
            </td>-->
            <td>
                是否为抓取数据
            </td>
            <td>
                是否已发布
            </td>
            <td>
                功能
            </td>
        </tr>
        <volist name="list" id="l">
            <tr>
                <td>
                    <a href="javascript:;" title="{$l.name}">{$l.name|msubstr=0,30 }</a>
                </td>
                <!--<td t_id="{$l.id }">
                <if condition="$l.fine eq 1">是
                    <else />否
                </if>
                </td>-->
                <td>
            <if condition="$l.auto_load eq 1">是
                <else />否
            </if>
            </td>
            <td>
            <if condition="$l.release eq 1">是
                <else />否
            </if>
            </td>
            <td>
                <a href="#" t_id = "{$l.id }" class="a_type_update">修改</a>/
                <!--<if condition="$l.auto_load eq 1">
                                <a href="#" t_id = "{$l.id }" class="a_type_update_auto_load">修改</a>/
                                <else />
                                <a href="#" t_id = "{$l.id }" class="a_type_update">修改</a>/
                           </if>-->
                <!--<if t_id="${$l.id }" condition="$l.fine eq 1">
                    <a href="#" t_id = "{$l.id }" fine ="0" class="a_type_fine"> 取消精品推荐</a>
                    <else />
                    <a href="#" t_id = "{$l.id }" fine="1" class="a_type_fine">添加精品推荐</a>
                </if> -->

                <a href="#" t_id = "{$l.id }" class="a_type_delete">删除</a>/
                <a href="__APP__/App/appComment/id/{$l.id }.shtml" class="a_type_comment">评论</a>
            </td>
            </tr>
        </volist>
    </table>
</div>
<div class="clear"></div>
<div id="div_news_page_list" class="margintop10">
    <div class="sabrosus">
        {$show }
    </div>
</div>
<form id="frm_hidden_app" action="__URL__" method="post">
    <input type="hidden" name="type" value="{$type }" />
</form>

<div id="div_type_dialog" rootTypeId ="" childTypeId =""></div>


